package com.aaa.lx1031;

/**
 * @author 荆豪峰
 * @version 1.0
 */
public class MyTicket implements Runnable{
    private int ticket=100;
    private static Object lock=new Object();
    @Override
    public void run() {
        while (true){
           synchronized (lock) {
               if (ticket >= 0) {
                   System.out.println(Thread.currentThread().getName() + "卖出了一张票"+ticket--);

               }
           }
        }
    }
}
